package com.qh.resourcehub.program.security.controller;

import com.qh.resourcehub.program.dto.SecurityAssessmentDto;
import com.qh.resourcehub.program.security.service.SecurityAssessmentExamineService;
import com.qh.resourcehub.program.vo.SecurityAssessmentVo;
import com.qh.resourcehub.utils.ApiResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
//青海省气象信息中心信息系统安全风险评估检查报告（数据服务室）
@RestController
@RequestMapping("/securityAssessmentExamine")
public class SecurityAssessmentExamineController {
    @Autowired
    private SecurityAssessmentExamineService securityAssessmentService;
    /*
     * @Description:
     * @param 查询审核信息
     * @return
     * @Author: Y6
     * @Date: 2025/4/18 14:19
     */
    @PostMapping("/querySecurityAssessmentExamineData")
    public ApiResponse querySecurityAssessmentExamineData(@RequestBody SecurityAssessmentDto securityAssessmentDto) {
        try {
            List<SecurityAssessmentVo> data = securityAssessmentService.querySecurityAssessmentExamineData(securityAssessmentDto);
            if (data.size()>0){
                return ApiResponse.succeed(data);
            }else {
                return ApiResponse.succeedNoData();
            }
        }catch (Exception e){
            e.printStackTrace(); // 打印完整堆栈信息
            return ApiResponse.succeedRequestErr("查询失败: " + e.getMessage()); // 返回详细错误信息
        }
    }

    /**examine
     * 安全风险评估检查报告通过
     * @param
     * @return
     */
    @PostMapping("/ApplicationPass")
    public ApiResponse ApplicationPass(@RequestBody SecurityAssessmentDto securityAssessmentDto) {
        try {
            int i = securityAssessmentService.ApplicationPass(securityAssessmentDto);
            if (i>0){
                return ApiResponse.succeedRequest();
            }else {
                return ApiResponse.succeedRequestNo();
            }
        }catch (Exception e){
            e.printStackTrace(); // 打印完整堆栈信息
            return ApiResponse.succeedRequestErr("操作失败: " + e.getMessage()); // 返回详细错误信息
        }
    }
    /**examine
     * 安全风险评估检查报告驳回
     * @param
     * @return
     */
    @PostMapping("/ApplicationReject")
    public ApiResponse ApplicationReject(@RequestBody SecurityAssessmentDto securityAssessmentDto) {
        try {
            int i = securityAssessmentService.ApplicationReject(securityAssessmentDto);
            if (i>0){
                return ApiResponse.succeedRequest();
            }else {
                return ApiResponse.succeedRequestNo();
            }
        }catch (Exception e){
            e.printStackTrace(); // 打印完整堆栈信息
            return ApiResponse.succeedRequestErr("操作失败: " + e.getMessage()); // 返回详细错误信息
        }
    }
}